<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <!--<meta http-equiv="X-UA-Compatible" content="IE=edge">-->
        <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
        <meta name="renderer" content="webkit">
        <title>运营平台登录</title>
        <link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/css/common.css" />
        <script src="{:get_style_cdnurl()}paimai/yunying/js/jquery-1.11.1.js" type="text/javascript"></script>
        <script src="{:get_style_cdnurl()}paimai/cheshan/js/common.js" type="text/javascript"></script>
        <style>
            body{overflow:hidden}
            @media screen and (max-height:700px){
                .loginMian{ background:url({:get_style_cdnurl()}paimai/yunying/images/login_pic1.jpg) no-repeat center center;height: auto;width:100%; display:block; position:relative;padding:80px 0;}
                .loginBtn{width:500px; background:#fff;height:360px;border:solid 1px #999;display:block;}
            }
        </style>
        <script>
            $(function () {
                $("#number").focus(function () {
                    if ($(this).val() == "账号：" || $(this).val() == "账号不能为空") {
                        $(this).val("");
                    }
                }).blur(function () {
                    if ($(this).val() == "") {
                        $(this).val("账号：");
                    }

                });

                $("#password").focus(function () {
                    if ($(this).val() == "密码：" || $(this).val() == "密码不能为空") {
                        $(this).val("");
                        $(this).attr("type", "password");
                    }
                }).blur(function () {
                    if ($(this).val() == "") {
                        $(this).val("密码：");
                        $(this).attr("type", "text")
                    }
                });

                $("#auth_code").focus(function(){
                    if($(this).val()=="验证码："||$(this).val()=="验证码不能为空"){
                        $(this).val("");
                    }
                }).blur(function(){
                    if($(this).val()==""){
                        $(this).val("验证码：");
                    }
                })


                $(".loginBtn ul li .login-btn").click(function () {
                    var user_name = $("#number").val();
                    var password = $("#password").val();
                    var auth_code = $("#auth_code").val();

                    if ( user_name == "" || user_name == "账号：") {
                        $("#number").val("账号不能为空").css({"border": "solid 1px #ff0000", "color": "#ff0000"})
                        return
                    } else if (user_name == "账号不能为空") {
                        $("#number").css({"border": "solid 1px #ff0000", "color": "#ff0000"});
                        return
                    } else {
                        $("#number").css({"border": "solid 1px #20ab4f", "color": "#666"})
                    }

                    if (password == "" || password == "密码：") {
                        $("#password").val("密码不能为空").css({"border": "solid 1px #ff0000", "color": "#ff0000"});
                        return false;
                    } else if (password == "密码不能为空") {
                        $("#password").css({"border": "solid 1px #ff0000", "color": "#ff0000"});
                        return false;
                    } else {
                        $("#password").css({"border": "solid 1px #20ab4f", "color": "#666"})
                    }

                    <?php if(APP_STATUS !='dev' && APP_STATUS !='test'):?>

                    if(auth_code==""||$("#auth_code").val()=="验证码："){
                        $("#auth_code").val("验证码不能为空").css({"border":"solid 1px #ff0000","color":"#ff0000"})
                        return false
                    }else if(auth_code=="验证码不能为空"){
                        $("#auth_code").css({"border":"solid 1px #ff0000","color":"#ff0000"});
                        return false
                    }else{
                        $("#auth_code").css({"border":"solid 1px #20ab4f","color":"#666"})
                    }

                    <?php endif;?>

                    login();
                });

                $(".obtainBtn").click(function(){
                    var user_name = $("#number").val();
                    if(user_name=='' || user_name=='账号：'){
                        delay_alert("请输入用户名",'500');
                        return false;
                    }
                    var password = $("#password").val();
                    if(password=='' || password=='密码：'){
                        delay_alert('密码不能为空','500');
                        return false;
                    }

                    $(".obtainBtn").attr("disabled", "true");
                    $(".obtainBtn").css({"background":"#ddd","border":"solid 1px #ddd","color":"#535353"});
                    $.post('/Emp/getAuthCode',{'user_name':user_name,'password':password},function (data) {
                        if(data.code!=200){
                            $(".obtainBtn").removeAttr("disabled");
                            $(".obtainBtn").css({"background":"#20ab4f","border":"solid 1px #20ab4f","color":"#fff"});
                            delay_alert(data.msg,1000);
                            return
                        }
                        countdown();
                    },'json');
                })

            });

            function countdown() {
                var i = 60;
                var timer;
                clearInterval(timer)
                timer = setInterval(function () {
                    i--;
                    $(".obtainBtn").val(i + "秒倒计时");
                    $(".obtainBtn").css({"background":"#ddd","border":"solid 1px #ddd","color":"#535353"});
                    $(".obtainBtn").attr("disabled", "true");
                    if (i < 10) {
                        $(".obtainBtn").val("0" + i + "秒后可重发");
                    } else {
                        $(".obtainBtn").val("" + i + "秒后可重发");
                    }
                    if (i == 1) {
                        $(".obtainBtn").val("获取验证码");
                        $(".obtainBtn").removeAttr("disabled");
                        $(".obtainBtn").css({"background":"#20ab4f","border":"solid 1px #20ab4f","color":"#fff"});
                        clearInterval(timer);
                    }
                }, 1000)
            }

            function login() {
                $('#number').css('color', '#000');
                $('#password').css('color', '#000');
                //$('#auth_code').css('color', '#000');

                var post_data = $('form').serialize();
                jQuery.post('{$Think.const.WEB_URL}Emp/ci_login?t=' + Math.random(), post_data, function (res) {
                    if (res.code == 200) {
                        location.reload();
                    } else {
                        delay_alert(res.msg);
                        if (res.code == 2) {
                            $('#name').css('color', '#ff0000');
                            $('#password').css('color', '#ff0000');
                        } else if (res.code == 1) {
                            $('#yanzheng').css('color', '#ff0000');
                        }
                    }
                }, 'json');
                return false;
            }


        </script>
    
    </head>

    <body>
        <div class="loginContent">
            <div class="logo"><img src="{:get_style_cdnurl()}paimai/yunying/images/yun_logo1.jpg" /></h1></div>
            <div class="loginMian">
                <div class="loginBtn">
                    <form action="/Emp/ci_login" target="_blank" >
                        <ul>
                            <li>
                                <input name="user_name" type="text" value="账号：" id="number" />
                            </li>
                            <li>
                                <input name="passwd" type="text" value="密码：" id="password" />
                            </li>
                            <?php if(APP_STATUS !='dev' && APP_STATUS !='test'):?>
                            <li class="clearfix">
                                <input name="auth_code" type="text" value="验证码：" id="auth_code" class="obtainText" />
                                <input type="button" value="获取验证码" class="obtainBtn" />
                            </li>
                            <?php endif;?>
                            <li>
                                <input id="login_bt" type="button" value="登录" class="login-btn"  />
                            </li>
                        </ul>
                    </form>
                </div>
            </div>
        </div>
    </body>
</html>